t = int(input())
for i in range(t):
n, m, k = map(int, input().split())
T = [[ s == "*" for s in input()] for y in range(n)]
Q = [[b for b in l] for l in T]
b = 1
for i in range(n):
for j in range(m):
if Q[i][j]:
d = 0
while j-d >= 0 and j+d < m and i-d >= 0 and T[i-d][j-d] and T[i-d][j+d]:
d += 1
if d - 1 >= k:
for s in range(d):
Q[i-s][j-s] = 0
Q[i-s][j+s] = 0
else:
b = False
if not any(any(l) for l in Q):
print("YES")
else:
print("NO")
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <complex>
#include <fstream>
#define ll long long
#define inf 1e9 + 8
#define sinf 1e17 + 500
#define ld long double
#define ull unsigned long long
#define pi acos(-1)
#define lp(a, b, c, d) for (ll a = b; a < c; a += d)
//#define endl '\n'
#define EPS 1e-12
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define mod 1000000007
using namespace std;
const ll N = 20, SEG = (1<<(int)(ceil(log2(N)) +1 ));
ll gcd(ll a , ll b )
{
if(b==0)return a ;
return gcd(b , a%b);
}
int n ,m , k ;
char gr[N][N];
int tallest(int r ,int c )
{
int pr = 1 ;
while(r-pr >=0 && c-pr >=0 && c+pr <m && (gr[r-pr][c-pr] == '*' ||gr[r-pr][c-pr] == '#') && (gr[r-pr][c+pr] == '*' ||gr[r-pr][c+pr] == '#') )
{
pr++;
}
return pr-1;
}
void ch(int r , int c ,int d)
{
gr[r][c]='#';
for(int i=1;i<=d;i++)
{
gr[r-i][c-i] = gr[r-i][c+i] = '#';
}
}
int main()
{
IO
int t ;
cin>>t;
while(t--)
{
cin>>n>>m>>k;
for(int i=0;i<n;i++)
{
cin>>gr[i];
}
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)if(gr[i][j]=='*')
{
int g = tallest(i,j);
if(g >= k)
{
ch(i,j,g);
// for(int i=0;i<n;i++)
// {
// cout<<gr[i]<<endl;
// }
// cout<<endl;
}
}
}
bool res =1 ;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(gr[i][j]=='*')
{
res = 0 ;
goto br;
}
}
}
br:
cout<<(res ? "YES" : "NO")<<endl;
}
return 0;
}
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |
Differences of the permutations | Doctor's Secret |
Back to School | I am Easy |
Teddy and Tweety | Partitioning binary strings |
Special sets | Smallest chosen word |
Going to office | Color the boxes |
Missing numbers | Maximum sum |
13 Reasons Why | Friend's Relationship |
Health of a person | Divisibility |
A. Movement | Numbers in a matrix |
Sequences | Split houses |
Divisible | Three primes |
Coprimes | Cost of balloons |
One String No Trouble | Help Jarvis! |